package com.itheima.myreflect2.Student.threaddemo9;

/**
 * @program: Myset
 * @description: 定义线程要访问的类
 * @author: xuejingjing
 * @create: 2021-06-19 10:50
 **/

//这个类是多线程要实现的参数，所以要实现runnable接口
public class Ticket implements Runnable {

        //定义100张票

        private static int ticket =100;

    @Override
    public void run() {
        while(true){
            if(ticket ==0){
                //卖完了
                break;
            }else{

                //线程执行到这里，睡100毫秒
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                ticket--;
                System.out.println(Thread.currentThread().getName()+"-"+ticket+"张票");
            }
    }





    }
}
